import http from './http'
import { news } from './mock'

let newsProxy = ''
let weatherProxy = ''
if(process.env.NODE_ENV === 'production') {
  newsProxy = 'http://v.juhe.cn'
  weatherProxy = 'https://devapi.qweather.com/v7/weather'
} else {
  newsProxy = '/news'
  weatherProxy = '/weather'
}

export function newsList(type = 'top', page = 1, page_size = 10) {
  return http.get(newsProxy + '/toutiao/index', {
    params: {
      key: '0813d396bfb64f752134f75ac231a694',
      type,
      page,
      page_size
    }
  })
  // return Promise.resolve(news)
}

// 3天的天气预报
export function get3d(location) {
  return http.get(
    weatherProxy + '/3d',
    {
      params: {
        key: "ecb0ddafc1be42e5b8de6441080e6a49",
        location
      }
    }
  )
}